// 活动相关API接口
import request from '@/utils/request'
import type { ActivityForm, ActivityQueryParams, EnrollForm } from './type'

// 发布活动
export const reqPublishActivity = (data: ActivityForm) => {
  return request.post('/activity/publish', data)
}

// 上传活动图片
export const reqUploadImage = (file: File) => {
  const formData = new FormData()
  formData.append('file', file)
  return request.post('/activity/upload/image', formData)
}

// 获取活动列表
export const reqGetActivityList = (params: ActivityQueryParams) => {
  return request.get('/activity/list', { params })
}

// 获取活动详情
export const reqGetActivityDetail = (id: number) => {
  return request.get(`/activity/detail/${id}`)
}

// 报名活动
export const reqEnrollActivity = (data: EnrollForm) => {
  return request.post('/activity/enroll', data)
}

// 取消报名
export const reqCancelEnroll = (activityId: number) => {
  return request.post('/activity/cancel', { activityId })
}

// 检查是否已报名
export const reqCheckEnrollStatus = (activityId: number) => {
  return request.get(`/activity/check-enroll/${activityId}`)
}

// 删除活动
export const reqDeleteActivity = (id: number) => {
  return request.delete(`/activity/delete/${id}`)
}

// 修改活动
export const reqUpdateActivity = (id: number, data: ActivityForm) => {
  return request.put(`/activity/update/${id}`, data)
}

